//
//  LBViewController.m
//  LBUIKit
//
//  Created by WuShiHai on 19/5/24.
//  Copyright (c) 2019 Lebbay. All rights reserved.
//

#import "LBViewController.h"
#import "LBUIKitMacroDefinition.h"

@interface LBViewController ()<UINavigationBarDelegate>

@property (nonatomic, strong, readwrite) LBView *contentView;

@end

@implementation LBViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Override
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;
}

- (CGRect)contetViewFrame {
    CGFloat height = CGRectGetHeight(self.view.frame);
    CGFloat minY = 0;
    BOOL isShowNavigation = self.navigationController.navigationBarHidden == NO;
    BOOL isTranslucent = self.navigationController.navigationBar.isTranslucent;
    BOOL isTabBar = self.tabBarController;
    if (isShowNavigation && isTranslucent) {
        minY = IPHONE_NAVIGATION_BAR_HEIGHT;
        height -= IPHONE_NAVIGATION_BAR_HEIGHT;
    }
    if (isTabBar) {
        height -= IPHONE_TAB_BAR_HEIGHT;
    }
    return CGRectMake(0, minY, CGRectGetWidth(self.view.frame), height);
}

#pragma mark - init
- (LBView *)contentView {
    if (_contentView) {
        return _contentView;
    }
    
    _contentView = [[LBView alloc] initWithFrame:[self contetViewFrame]];
    _contentView.backgroundColor = [UIColor clearColor];
    [self.view addSubview:_contentView];
    [self.view sendSubviewToBack:_contentView];

    return _contentView;
}


@end
